package com.temi.demo;

import com.temi.demo.bean.ContactsListResult;
import com.temi.demo.net.BaseCallBack;
import com.temi.demo.net.HttpAPIService;
import com.temi.demo.net.NetManager;

import java.util.ArrayList;

import retrofit2.Call;

/**
 * Created by coco on 2018/6/26.
 */

public class ContactsPresenter extends BasePresenter<MVPCallback> {

    public void getContactsList(){
        HttpAPIService httpAPIService = NetManager.getInstance().getRetrofit().create(HttpAPIService.class);
        Call<ArrayList<ContactsListResult.ContactsData>> call = httpAPIService.getContactListResult();
        call.enqueue(new BaseCallBack<>(new BaseCallBack.CallbackListener<ArrayList<ContactsListResult.ContactsData>>() {
            @Override
            public void onSuccess(ArrayList<ContactsListResult.ContactsData> result) {
                if(getCallback() != null){
                    getCallback().onSuccess(result);
                }
            }

            @Override
            public void onError() {
                if(getCallback() != null){
                    getCallback().onFailure();
                }
            }
        }));
    }

}
